<template>
	<view class="goods-list">
		<block v-for="item in goods" :key="item.id">
			<view class="goods-item" @click="toDetail(item.id)">
				<image :src="item.img_url"/>
				<view class="price">
					<text>￥{{item.sell_price}}</text>
					<text>￥{{item.market_price}}</text>
				</view>
				<view class="name">{{item.title}}</view>
			</view>
		</block>
	</view>
</template>

<script>
	export default {
		props: {
			goods: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			toDetail(id) {
				this.$emit('goodsClick', id);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goods-list {
		display: flex;
		padding: 0 15rpx;
		flex-wrap: wrap;
		justify-content: space-between;
		.goods-item {
			margin: 10rpx 0;
			background-color: #fff;
			width: 355rpx;
			padding: 15rpx;
			box-sizing: border-box;
			image {
				width: 80%;
				height: 150rpx;
				display: block;
				margin: 0 auto;
			}
			.price {
				color: $main-color;
				font-size: 36rpx;
				margin: 20rpx 0 10rpx 0;
				text:nth-child(2) {
					color: #ccc;
					font-size: 28rpx;
					margin-left: 10rpx;
					text-decoration: line-through;
				}
			}
			.name {
				padding-bottom: 15rpx;
				padding-top: 10rpx;
				font-size: 28rpx;
			}
		}
	}
</style>
